package com.xm.controller.mobile;

import com.xm.pojo.Valve;
import com.xm.service.ValveService;
import com.xm.util.JSONMsg;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by wzl on 2018/4/11.
 */
@Controller
@RequestMapping("/m/valve")
public class ValveMobileController {
    @Resource
    private ValveService valveService;

    /**
     * 查询全部阀门信息方法
     *
     * @param valve
     * @return
     */
    @RequestMapping(value = "/selectValveList", method = RequestMethod.GET)
    @ResponseBody
    public JSONMsg selectAll(Valve valve) {
        JSONMsg jsonMsg = new JSONMsg();
        List<Valve> list = valveService.selectList(valve);
        //配合手机端类型接收
        for(Valve valveInfo :list){
            valveInfo.setCreateTime(null);
            valveInfo.setUpdateTime(null);
        }
        jsonMsg.setMsg(list);
        jsonMsg.setStatus(true);
        return jsonMsg;
    }

    /**
     * 查询阀门信息详情方法
     *
     * @param valve
     * @return
     */
    @RequestMapping(value = "/selectValveDetail", method = RequestMethod.GET)
    @ResponseBody
    public JSONMsg selectValveDetail(Valve valve) {
        JSONMsg jsonMsg = new JSONMsg();
        Valve valveInfo = valveService.selectOne(valve);
        valveInfo.setCreateTime(null);
        valveInfo.setUpdateTime(null);
        jsonMsg.setMsg(valveInfo);
        jsonMsg.setStatus(true);
        return jsonMsg;
    }
}
